﻿package kliment.utils {
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	/**
	 * ...
	 * @author	Kliment
	 * @version	1.0.5
	 * 
	 * class name: kliment.utils._Sprite
	 */
	public final class _Sprite {
		
		static public function hitTestBoundsMouse(target_mc:Sprite):Boolean {
			return hitTestBounds(target_mc, target_mc.mouseX, target_mc.mouseY);
		}
		
		static public function hitTestBounds(target_mc:Sprite, x:Number, y:Number):Boolean {
			var boundsRect:Rectangle = target_mc.getBounds(target_mc);
			if (x >= boundsRect.x && x <= boundsRect.width && y >= boundsRect.y && y <= boundsRect.height) 
				return true;
			return false;
		}
		
		static public function hitTestMouse(target_mc:Sprite):Boolean {
			var point:Point = target_mc.localToGlobal(new Point(target_mc.mouseX, target_mc.mouseY));
			return target_mc.hitTestPoint(point.x, point.y);
		}
		
		static public function remove(victim:DisplayObject):DisplayObject {
			if (!victim) return null;
			if (victim.parent)
				victim.parent.removeChild(victim);
			return victim;
		}
		
		static public function clear(target_mc:Sprite):void {
			while (target_mc.numChildren) 
				target_mc.removeChildAt(0);
		}
		
		/*static public function getBounds(target_mc:Sprite):Rectangle {
			return toBounds(target_mc.getBounds(target_mc._parent));
		}*/
		
	}

}